home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / Visual Basic 6.0 Utilities / Multi-Language Add-In for Visual Basic 6.0 / MultiLang.msi / _F8FA66EF9FD611D5BEFD0020182C1E5C < prev    next >
Encoding:
Text File  |  2001-09-12  |  2.4 KB  |  67 lines

  1. Attribute VB_Name = "MlStringModule"
  2. Option Explicit
  3.  
  4. Public ml_CurrentLanguageId As Long
  5. Public Const ml_LanguageCount As Long = 2
  6. Public ResLoader As New ResourceReader
  7. Public InVbIde As Boolean
  8.  
  9. Public Function ml_string(ByVal StringID As Long, Optional ByVal Text As String = "") As String
  10.   'NOTE: ResLoader fails when running in the VB debugger!
  11.   If InVbIde Then
  12.     ml_string = LoadResString(StringID)
  13.   Else
  14.     ml_string = ResLoader.ResString(StringID, ml_CurrentLanguageId)
  15.   End If
  16. End Function
  17.  
  18. Public Function ml_LanguageName(ByVal LangIndex As Long) As String
  19.   Select Case LangIndex
  20.     Case 1033: ml_LanguageName = "English (United States)"
  21.     Case 1041: ml_LanguageName = "Japanese"
  22.     Case Else: ml_LanguageName = "Invalid Language Index"
  23.   End Select
  24. End Function
  25.  
  26. Public Sub ml_ChangeLanguage(ByVal LanguageID As Long, ByVal Language As String)
  27.   
  28.   'If an application uses UserControls or Class Modules compiled as separate
  29.   'projects, then these projects may (a) not support the same languages or
  30.   '(b) not use the same ID number for a given language.
  31.   'If the language is changed at run time, an event can be fired via the
  32.   'MLSupport object, and received in all projects.
  33.   'This function checks whether the ID and Language name match before accepting
  34.   'the language change. If they do not match, then it searches for language
  35.   'using the language name not the ID. If the language is not found, then the
  36.   'language is not changed.
  37.   
  38.   'Check whether the LanguageID and the Language match in this project.
  39.   'Use StrComp() for case insensitive comparison
  40.   If LanguageID = 0 Then
  41.     'Illegal value. Can occur is control is started in
  42.     'container which does not support Multi-Language system
  43.     ml_CurrentLanguageId = 1
  44.   ElseIf StrComp(ml_LanguageName(LanguageID), Language, vbTextCompare) = 0 Then
  45.     ml_CurrentLanguageId = LanguageID
  46.   Else
  47.     'LanguageID may be different in this project.
  48.     'Search for the language string.
  49.     For LanguageID = 1 To ml_LanguageCount
  50.       If StrComp(ml_LanguageName(LanguageID), Language, vbTextCompare) = 0 Then
  51.         ml_CurrentLanguageId = LanguageID
  52.         Exit For
  53.       End If
  54.     Next
  55.   End If
  56.   
  57. End Sub
  58.  
  59. Public Function ml_LanguageIds() As Variant
  60.   ml_LanguageIds = Array(1033, 1041)
  61. End Function
  62.  
  63. Public Function SetInVbIde() As Boolean
  64.   InVbIde = True
  65.   SetInVbIde = True
  66. End Function
  67.